package com.flk.oauth.vaildatecode.sms;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * @author xxwy
 * on 2018/8/24 0024
 */
@Slf4j
@Data
@Component
@PropertySource("classpath:others.properties")
@ConfigurationProperties(prefix="aliyun.sms")
public class DefaultSmsCodeSender implements SmsCodeSender {

    private String accessKeyId;
    private String accessKeySecret;
    private String signName;
    private String loginTemplateCode;


    @Override
    public void send(String mobile, String code) {
        log.info("向手机号：" + mobile + "，发送验证码：" + code);
        String templateParam = "{\"code\":\"" + code + "\"}";
        AliyunSmsUtils.sendCode(accessKeyId,accessKeySecret,mobile,signName,loginTemplateCode,templateParam);
    }


}
